<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
	public function index()
	{	
		$sql = "select u.uid,
				u.name as username,
			    mi.id as mid,    
			    mi.name as mname,
				mi.describes as describes,
				mp.price as price,
				(select ifnull(sum(rating)/count(m_id),0) as rating from model_rating where m_id = mi.id) as rating,
				(select CONCAT(path , name) from model_picture where m_id = mi.id and cover = 1) as picture
			from user_model mi,
				model_price mp,
				user u
			where mi.uid = u.uid and mi.id = mp.m_id limit 0,20";
		$query = $this->db->query($sql);
		$data['products'] = $query->result(); 
		$data['tag'] = date('Ymd');
		$data['ser'] = 'http://'.$_SERVER['SERVER_NAME'];
		$data['cart_count'] = 1;
		$data['is_login'] = TRUE;
		$data['logoName'] = 'Super3D';
		$data['targetUrl'] = $data['ser'] . $_SERVER['REQUEST_URI'];
		$data['username'] = 'Stony';
		$data['uid'] = '1000001';
		$this->load->view('home', $data);
	}
}